package com.atguigu.c_designed.m2stucturalModel.s7proxy;

public class StaticProxyClient {
    public static void main(String[] args) {
        TeacherDao teacherDao = new TeacherDaoImpl();
        TeacherProxy teacherProxy = new TeacherProxy(teacherDao);
        String teach = teacherProxy.teach();
        System.out.println(teach);
    }
}

interface TeacherDao {
    String teach();
    String Teach2(String name);
}

class TeacherDaoImpl implements TeacherDao {
    @Override
    public String teach() {
        System.out.println("teacher teaching.....");
        return "I am a teacher ";
    }

    @Override
    public String Teach2(String name) {
        System.out.println(name+"teacher teaching.....");
        return "I am  teacher " +name;
    }
}

class TeacherProxy implements TeacherDao {

    private TeacherDao target;

    public TeacherProxy(TeacherDao target) {
        this.target = target;
    }

    @Override
    public String Teach2(String name) {
        return null;
    }

    @Override
    public String teach() {
        System.out.println("静态代理开始");
        String teach = target.teach();
        System.out.println("静态代理结束");
        return teach;
    }
}